import 'package:flutter/material.dart';
import 'package:xinxuan/common/appbar_util.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/common/system_address_item.dart';
import 'package:xinxuan/controllers/my_controller/address_controller/address_area_controller.dart';
import 'package:xinxuan/controllers/my_controller/address_controller/address_controller.dart';
import 'package:get/get.dart';
import 'package:xinxuan/utils/color_util.dart';

class AddressArea extends StatelessWidget {

  final AddressController addressController = Get.find();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarUtil(
        title: '选择区',
        backgroundColor: pageBgColor,
      ),
      body: GetBuilder<AddressAreaController>(
        init: AddressAreaController(),
        builder: (controller) {
          return ScrollConfigurationCommon(child: ListView(
            children: controller.areaArr.map((item) {
              return SystemAddressItem(
                title: '${item.title}', 
                isSelected: addressController.providerItem.value.id == item.id, 
                onTap: () {
                  addressController.changeAreaAddress(item);
                  addressController.update();
                  Get.back();
                }
              );
            }).toList(),
          ));
        },
      ),
    );
  }

}